import { createRouter, createWebHistory } from 'vue-router'
import { renderIcon } from '../utils'
import {
    DashboardOutlined,
    WarningOutlined,
    SettingOutlined
} from '@vicons/antd'

import Main from '../layout/Main.vue'

export const loginRouter = {
    path: '/login',
    name: 'login',
    title: '登陆'
}

export const mainRouter = [
    {
        path: '/',
        name: 'index',
        redirect: { name: 'workplace' },
        component: Main
    },
    {
        path: '/dashboard',
        name: 'dashboard',
        meta: { title: '仪表盘', icon: renderIcon(DashboardOutlined) },
        component: Main,
        children: [
            {
                path: 'workplace',
                name: 'workplace',
                meta: { title: '工作台' },
                component: () =>
                    import('../views/dashboard/workplace/index.vue')
            }
        ]
    },
    {
        path: '/error',
        name: 'error',
        meta: { title: '异常页', icon: renderIcon(WarningOutlined) },
        component: Main,
        children: [
            {
                path: '403',
                name: '403',
                meta: { title: '403' },
                component: () => import('../views/error/403/403.vue')
            }
        ]
    },
    {
        path: '/system',
        name: 'system',
        meta: { title: '系统设置', icon: renderIcon(SettingOutlined) },
        component: Main,
        children: [
            {
                path: 'setting',
                name: 'setting',
                meta: { title: '设置' },
                component: () => import('../views/dashboard/monitor/index.vue')
            }
        ]
    }
]

export const router = createRouter({
    history: createWebHistory(),
    routes: [loginRouter, ...mainRouter]
})
